package com.admin.service.vo;

import com.admin.persistence.sys.entity.UserGroup;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.stream.Collectors;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class SysUserGroup {

    private UserGroup userGroup;

    private List<SysUserGroup> children;

    private UserGroup fartherUserGroup;

    @Override
    public String toString() {
        String reuslt = "";
        if (!CollectionUtils.isEmpty(children)) {
            reuslt = children.stream().map(cur -> {
                return cur.toString();
            }).collect(Collectors.joining(",","[","]"));
        }


        return "SysUserGroup{" +
                "userGroup=" + userGroup.toString() +
                ", children=" + reuslt +
                ", fartherUserGroup=" + fartherUserGroup.toString() +
                '}';
    }
}
